//
//  Interface.swift
//  FrameProduct
//
//  Created by delegate on 2024/2/3.
//

import UIKit

public protocol Interface: CustomStringConvertible {}
public protocol Class: AnyObject {}

public protocol Themeable: Interface, Class {
    func themeDidChange(_ theme: Theme)
}

public protocol Viewable: Themeable where Self: UIView {
    func viewDidLoad()
    func viewWillAppear(_ animated: Bool)
    func viewDidAppear(_ animated: Bool)
    func viewWillDisappear(_ animated: Bool)
    func viewDidDisappear(_ animated: Bool)
}

public protocol ViewControllable: Interface, Class where Self: UIViewController {
    associatedtype ViewType: Viewable
    var rootView: ViewType! { get }
}

public protocol ViewModelControllable where T: ViewModelType, Self: ViewControllable {
    associatedtype T
    var viewModel: T? { get set }
    func bindToViewModel()
}
public protocol ReusableViewable: Interface, Class where Self: UIView {
    func prepareForReuse()
}

public protocol ReuseIdentifiable: Interface, Class {
    static var reuseIdentifier: String { get }
}
public protocol WrapperViewable: Interface, Class where Self: UIView {
    associatedtype ViewType: UIView
    var wrappedView: ViewType { get }
}

public protocol TableCellRepresentable {
    var rowHeight: CGFloat { get }
    func cellInstance(_ tableView: UITableView, indexPath: IndexPath, currentController: UIViewController?) -> UITableViewCell
}
public protocol TableHeaderRepresentable {
    var height: CGFloat { get }
    func headerView(_ tableView: UITableView, section: Int) -> UITableViewHeaderFooterView?
}
public protocol CollectionHeaderFooterRepresentable {
    var size: CGSize { get }
    func view(_ collectionView: UICollectionView, indexPath: IndexPath) -> UICollectionReusableView?
}
public protocol CollectionCellRepresentable {
    
    func cellInstance(_ collectionView: UICollectionView, indexPath: IndexPath, currentController: UIViewController?) -> UICollectionViewCell
    func collectionView(_ collectionView: UICollectionView, layout collectionViewLayout: UICollectionViewLayout, sizeForItemAt indexPath: IndexPath, numberOfColumns: Int, itemPadding: CGFloat, sectionInsets: UIEdgeInsets) -> CGSize
}
